#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int numSpecial(vector<vector<int>> &mat)
    {
        int rows = mat.size();
        int cols = mat[0].size();

        vector<int> rowSum(rows);
        vector<int> colSum(cols);

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                rowSum[i] += mat[i][j];
                colSum[j] += mat[i][j];
            }
        }

        int ans = 0;

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                if (mat[i][j] == 1 && rowSum[i] == 1 && colSum[j] == 1)
                {
                    ans++;
                }
            }
        }

        return ans;
    }
};

int main(int argc, char const *argv[])
{
    /* code */
    return 0;
}
